package com.sunny.design.prototype.shallow;

import java.util.Arrays;

/**
 * 浅克隆测试
 *  对象中包含的引用是同一个,修改一个,另一个也会被修改
 *
 * @author Sunny
 * @date 2019/12/31 16:39
 */
public class ShallowPrototypeTest {
    public static void main(String[] args) {
        ShallowPrototype prototype = new ShallowPrototype();
        prototype.setAge(1);
        prototype.setName("Sunny");
        prototype.setHobbies(Arrays.asList("123", "321"));

        ShallowPrototype prototype1 = prototype.clone();

        System.out.println(prototype);
        System.out.println(prototype1);
        //hobbies的引用是相同的
        System.out.println(prototype1.getHobbies() == prototype.getHobbies());
    }
}
